﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Maticsoft.Common;

namespace Maticsoft.Web.UserInfo
{
    public partial class UserRegist : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";
            if (this.txtUserName.Text.Trim().Length == 0)
            {
                strErr += "UserName不能为空！\\n";
            }
            if (this.txtUserPassword.Text.Trim().Length == 0)
            {
                strErr += "UserPassword不能为空！\\n";
            }
            //if (!PageValidate.IsNumber(txtGroupId.Text))
            //{
            //    strErr += "GroupId格式错误！\\n";
            //}
            if (this.txtUserPhoneNum.Text.Trim().Length == 0)
            {
                strErr += "UserPhoneNum不能为空！\\n";
            }
            if (this.txtUserEmail.Text.Trim().Length == 0)
            {
                strErr += "UserEmail不能为空！\\n";
            }
            //if (!PageValidate.IsDateTime(txtUserRegTime.Text))
            //{
            //    strErr += "UserRegTime格式错误！\\n";
            //}
            //if (this.txtUserStatus.Text.Trim().Length == 0)
            //{
            //    strErr += "UserStatus不能为空！\\n";
            //}

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string UserName = this.txtUserName.Text;
            string UserPassword = this.txtUserPassword.Text;
            //int GroupId = int.Parse(this.txtGroupId.Text);
            string UserPhoneNum = this.txtUserPhoneNum.Text;
            string UserEmail = this.txtUserEmail.Text;
            //DateTime UserRegTime = DateTime.Parse(this.txtUserRegTime.Text);
            //string UserStatus = this.txtUserStatus.Text;

            Maticsoft.Model.UserInfo model = new Maticsoft.Model.UserInfo();
            model.UserName = UserName;
            model.UserPassword = UserPassword;
            //注意 GroupId默认值待添加//model.GroupId = GroupId;
            model.UserPhoneNum = UserPhoneNum;
            model.UserEmail = UserEmail;
            //model.UserRegTime = UserRegTime;
            //注意UserStatus默认值待添加//model.UserStatus = UserStatus;

            Maticsoft.BLL.UserInfo bll = new Maticsoft.BLL.UserInfo();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "注册成功！", "UserRegist.aspx");
        }


    }
}